<?php
/**
 * Created by PhpStorm.
 * User: shiding
 * Date: 2019-06-14
 * Time: 17:03
 */

namespace App\Http\Repositories;


use App\Models\Link;

class LinkRepository
{
    protected $linkModel;

    public function __construct(Link $link)
    {
        $this->linkModel = $link;
    }

    public function getWaitAudit()
    {
        return $this->linkModel->getWaitAudit();
    }

    public function getLinkList()
    {
        return $this->linkModel->getLinkList();
    }

    public function auditLink($id)
    {
        return $this->linkModel->auditLink($id);
    }

    public function edit($params, $id = 0)
    {
        $params['audit_status'] = $this->linkModel::TRUE_STATUS;
        return $id
            ? $this->linkModel->insert($params)
            : $this->linkModel->where("id", $id)->update($params);
    }

    public function del($id)
    {
        return $this->linkModel->destroy($id);
    }

    public function enableLink($id, $status)
    {
        return $this->linkModel->enableLink($id, $status);
    }
}